package com.yonyou.isv.demo.openapi.api.staff;

import com.yonyou.isv.demo.openapi.api.*;
import com.yonyou.isv.demo.openapi.base.module.reponse.ApiDataArrayResponse;
import com.yonyou.isv.demo.openapi.base.module.reponse.ApiDataResponse;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * @description: 用友开放平台员工接口
 * @author: nishch
 * @create: 2021-07-05
 **/
@Component
public class StaffApi extends BaseOpenApi {

    public Map<String, Object> save(Map<String, Object> params) {
        ApiDataResponse apiDataResponse =  postForEntity(OpenApiURL.STAFF_SAVE,params, ApiDataResponse.class);
        return getData(apiDataResponse);
    }

    public Map<String, Object> detail(Map<String, String> params) {
        ApiDataResponse apiDataResponse =  getForEntity(OpenApiURL.STAFF_DETAIL,params, ApiDataResponse.class);
        return getData(apiDataResponse);
    }

    public Map<String, Object> list(Map<String, Object> params) {
        ApiDataResponse apiDataResponse =  postForEntity(OpenApiURL.STAFF_LIST,params, ApiDataResponse.class);
        return getData(apiDataResponse);
    }

    /**
     * 员工启用
     * @param params 请求参数
     * @return Map<String, Object>
     */
    public Map<String, Object> enable(Map<String, Object> params) {
        ApiDataResponse apiDataResponse =  postForEntity(OpenApiURL.STAFF_UNSTOP,params, ApiDataResponse.class);
        return getData(apiDataResponse);
    }

    /**
     * 用户通过员工编号绑定员工
     * @param params 请求参数
     * @return List<Map<String, Object>>
     */
    public List<Map<String, Object>> userBindStaff(Map<String, Object> params) {
        ApiDataArrayResponse apiDataResponse =  postForEntity(OpenApiURL.STAFF_BIND_USER,params, ApiDataArrayResponse.class);
        return getData(apiDataResponse);
    }
    /**
     * 通过用户id查询员工信息
     */
    public Map<String,Object> findByUserid(Map<String,Object> params)
    {
        ApiDataResponse apiDataResponse = postForEntity(OpenApiURL.STAFF_FIND_BY_USERID, params, ApiDataResponse.class);
        return getData(apiDataResponse);
    }
    /**
     * 员工停用
     */
    public Map<String,Object> stop(Map<String,Object> params)
    {
        ApiDataResponse apiDataResponse = postForEntity(OpenApiURL.STAFF_STOP, params, ApiDataResponse.class);
        return getData(apiDataResponse);
    }
    /**
     * 员工批量新增
     */
    public Map<String,Object> batchSave(Map<String,Object> params)
    {
        ApiDataResponse apiDataResponse = postForEntity(OpenApiURL.STAFF_BATCHSAVE, params, ApiDataResponse.class);
        return getData(apiDataResponse);
    }
}
